<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>工程首页</h1>
    <a href="/bmi.html">BMI身体质量指数测试</a>
    <hr>
    <input type="button" value="发get请求" @click="f1()">
    <hr>
    <input type="text" v-model="emp.name" placeholder="姓名">
    <input type="text" v-model="emp.salary" placeholder="工资">
    <input type="text" v-model="emp.job" placeholder="工作">
    <input type="button" value="发post请求" @click="f2()">
    <br>
    <h1>注册和登陆(异步版本)</h1>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登陆</a>
    <br>
    <h1>商品管理系统(异步版本)</h1>
    <a href="/insert.html">添加商品</a>
    <a href=""></a>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            emp: {name: "", salary: "", job: ""}
        },
        methods: {
            f1() {
                //发出异步请求
                /*发送get请求,服务器响应,调用响应方法,穿过来个对象*/
                axios.get("/helloAxios?info=tom").then(function (response) {
                    //response.data 代表服务器响应的数据.
                    alert(response.data);
                })
            },
            f2() {
                //发生异步请求
                //发送post请求,并且把和页面进行双向绑定过的员工对象里面的数据提交
                axios.post("/helloPost",v.emp).then(function (responce) {
                    alert(responce.data);
                })
            }
        }
    })
</script>
</body>
</html>